/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package client;

import client.ihm.IHMProto1;
import client.network.NetworkClient;
import client.controller.VisitorsLayerController;
import common.model.Visitor;
import client.ihm.view.VisitorLayer2D;
import client.ihm.view.VisitorLayerContainer;
import common.model.Position;
import java.awt.Color;
import java.awt.Dimension;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 *
 * @author nicolas
 */
public class Client {
    
    public static void main(String args[]) {
        //NetworkClient networkClient = new NetworkClient(new Visitor("TEST", new Position()));
        final Logger logger = LoggerFactory.getLogger(Client.class);

        //Create LocalVisitor
        java.util.Random rand = new java.util.Random();
        int leNombreAleatoire = rand.nextInt(100); //Will be the username for the moment
        Visitor localVisitor = new Visitor(String.valueOf(leNombreAleatoire), new Position(rand.nextInt(200),rand.nextInt(200),0));
        logger.debug("LocalVisitor created : {}",localVisitor);
        
        NetworkClient networkClient = new NetworkClient(localVisitor);

        VisitorLayer2D visitorLayer2D = new VisitorLayer2D();
        visitorLayer2D.setBackground(Color.WHITE);
        visitorLayer2D.setPreferredSize(new Dimension(400, 200));
        VisitorsLayerController controller = new VisitorsLayerController(visitorLayer2D, localVisitor, networkClient);
        visitorLayer2D.setController(controller);
        IHMProto1 ihm = new IHMProto1(localVisitor, networkClient);
        ihm.setVisible(true);
        int px = ihm.getLocationOnScreen().x;
        int py = ihm.getLocationOnScreen().y + ihm.getHeight();
        VisitorLayerContainer.showOnFrame(visitorLayer2D, "2D View", px, py);
    }
}
